package edu.stonybrook.cs.gars.shared.users;

/**
 * @author Tony Arra Roles that define the permissions for a user. A user may
 *         only have one role.
 *         To construct from a string, use the fromString(String) method.
 */
public enum Role {
	/**
	 * Chair of the graduate admissions committee
	 */
	CHAIR("Chair"),
	/**
	 * Member of the School's faculty
	 */
	FACULTY("Faculty"),
	/**
	 * For now value will be unused
	 */
	STAFF("Staff");
	
	private String role;

	Role(String role) {
		this.role = role;
	}

	/**
	 * Use this to construct enum from a string
	 * @param text
	 * @return
	 */
	public static Role fromString(String text) {
	    if (text != null) {
	      for (Role r : Role.values()) {
	        if (text.equalsIgnoreCase(r.role)) 
	          return r;
	      }
	    }
	    return null;
	  }
	    
	/**
	 * Returns the non-abbreviated form of the subject
	 * 
	 * @return long-form of subject
	 */
	public String toString() {
		return role;
	}
}
